# Don't use the bundled gcc, see rust-lang/rust#17442
rm -rf rustc/bin/rustlib/$triple/bin
# Don't use bundled gcc libs, see rust-lang/rust#19519
- rm -rf rustc/bin/rustlib/$triple/libmingw*.a
+ rm -rf rustc/bin/rustlib/$triple/lib/libmingw*.a
rm -f rust-nightly-$triple.exe
fi
name = "cargo"
version = "0.1.0"
dependencies = [
- "curl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.6.15 (git+https://github.com/alexcrichton/docopt.rs?ref=update)",
"flate2 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)",
+ "log 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"registry 0.1.0",
- "semver 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "tar 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "toml 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "semver 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tar 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "toml 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "curl"
-version = "0.1.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "curl-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "curl-sys"
-version = "0.1.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libz-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "docopt"
version = "0.6.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+source = "git+https://github.com/alexcrichton/docopt.rs?ref=update#ad176d540d344beb932cea8aa6270b92696a48bc"
+dependencies = [
+ "regex 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
[[package]]
name = "flate2"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "miniz-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "miniz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "git2"
-version = "0.1.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libgit2-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "libgit2-sys"
-version = "0.1.1"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libssh2-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "log"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "regex 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "miniz-sys"
-version = "0.1.0"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "regex"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "registry"
version = "0.1.0"
dependencies = [
- "curl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "tar"
-version = "0.1.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "time"
-version = "0.1.2"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "toml"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "url"
-version = "0.2.5"
+version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
path = "src/cargo/lib.rs"
[dependencies]
-docopt = "0.6.14"
toml = "0.1.4"
url = "0.2.0"
semver = "0.1.0"
git2 = "0.1.0"
glob = "0.1.0"
time = "0.1.0"
+log = "0.1.0"
+
+[dependencies.docopt]
+git = "https://github.com/alexcrichton/docopt.rs"
+branch = "update"
[dev-dependencies.hamcrest]
git = "https://github.com/carllerche/hamcrest-rust.git"
execute_main_without_stdin(execute, true, USAGE)
}
-macro_rules! each_subcommand( ($macro:ident) => ({
- $macro!(bench)
- $macro!(build)
- $macro!(clean)
- $macro!(config_for_key)
- $macro!(config_list)
- $macro!(doc)
- $macro!(fetch)
- $macro!(generate_lockfile)
- $macro!(git_checkout)
- $macro!(help)
- $macro!(locate_project)
- $macro!(login)
- $macro!(new)
- $macro!(owner)
- $macro!(package)
- $macro!(pkgid)
- $macro!(publish)
- $macro!(read_manifest)
- $macro!(run)
- $macro!(search)
- $macro!(test)
- $macro!(update)
- $macro!(verify_project)
- $macro!(version)
- $macro!(yank)
-}) )
+macro_rules! each_subcommand{ ($macro:ident) => ({
+ $macro!(bench);
+ $macro!(build);
+ $macro!(clean);
+ $macro!(config_for_key);
+ $macro!(config_list);
+ $macro!(doc);
+ $macro!(fetch);
+ $macro!(generate_lockfile);
+ $macro!(git_checkout);
+ $macro!(help);
+ $macro!(locate_project);
+ $macro!(login);
+ $macro!(new);
+ $macro!(owner);
+ $macro!(package);
+ $macro!(pkgid);
+ $macro!(publish);
+ $macro!(read_manifest);
+ $macro!(run);
+ $macro!(search);
+ $macro!(test);
+ $macro!(update);
+ $macro!(verify_project);
+ $macro!(version);
+ $macro!(yank);
+}) }
/**
The top-level `cargo` command handles configuration and project location
args.insert(0, command.to_string());
args.insert(0, os::args()[0].clone());
- macro_rules! cmd( ($name:ident) => (
+ macro_rules! cmd{ ($name:ident) => (
if command.as_slice() == stringify!($name).replace("_", "-").as_slice() {
mod $name;
shell.set_verbose(true);
cargo::process_executed(r, shell);
return Ok(None)
}
- ) )
- each_subcommand!(cmd)
+ ) }
+ each_subcommand!(cmd);
execute_subcommand(command.as_slice(), args.as_slice(), shell);
Ok(None)
}
}
- macro_rules! add_cmd( ($cmd:ident) => ({
+ macro_rules! add_cmd{ ($cmd:ident) => ({
commands.insert(stringify!($cmd).replace("_", "-"));
- }) )
+ }) }
each_subcommand!(add_cmd);
commands
}
let regex = Regex::new(r"^([^ ]+) ([^ ]+) \(([^\)]+)\)$").unwrap();
let captures = regex.captures(string.as_slice()).expect("invalid serialized PackageId");
- let name = captures.at(1);
- let version = semver::Version::parse(captures.at(2)).ok().expect("invalid version");
- let source_id = SourceId::from_url(captures.at(3).to_string());
+ let name = captures.at(1).unwrap();
+ let version = captures.at(2).unwrap();
+ let url = captures.at(3).unwrap();
+ let version = semver::Version::parse(version).ok().expect("invalid version");
+ let source_id = SourceId::from_url(url.to_string());
Ok(PackageId {
inner: Arc::new(PackageIdInner {
}
impl<'a> PackageRegistry<'a> {
- pub fn new<'a>(config: &'a Config<'a>) -> PackageRegistry<'a> {
+ pub fn new(config: &'a Config<'a>) -> PackageRegistry<'a> {
PackageRegistry {
sources: SourceMap::new(),
source_ids: HashMap::new(),
let captures = regex.captures(string.as_slice())
.expect("invalid serialized PackageId");
- let name = captures.at(1);
- let version = captures.at(2);
+ let name = captures.at(1).unwrap();
+ let version = captures.at(2).unwrap();
let source = captures.at(3);
- let source_id = if source == "" {
- None
- } else {
- Some(SourceId::from_url(source.to_string()))
- };
+ let source_id = source.map(|s| SourceId::from_url(s.to_string()));
Ok(EncodablePackageId {
name: name.to_string(),
use std::collections::hash_map::{HashMap, Values, MutEntries};
use std::fmt::{mod, Show, Formatter};
use std::hash;
-use std::iter;
use std::mem;
use std::sync::Arc;
use serialize::{Decodable, Decoder, Encodable, Encoder};
}
pub type Sources<'a, 'src> = Values<'a, SourceId, Box<Source+'src>>;
-pub type SourcesMut<'a, 'src> = iter::Map<'static, (&'a SourceId,
- &'a mut Box<Source+'src>),
- (&'a SourceId, &'a mut (Source+'src)),
- MutEntries<'a, SourceId, Box<Source+'src>>>;
+
+pub struct SourcesMut<'a, 'src: 'a> {
+ inner: MutEntries<'a, SourceId, Box<Source + 'src>>,
+}
impl<'src> SourceMap<'src> {
pub fn new() -> SourceMap<'src> {
}
pub fn sources_mut<'a>(&'a mut self) -> SourcesMut<'a, 'src> {
- self.map.iter_mut().map(|(k, v)| (k, &mut **v))
+ SourcesMut { inner: self.map.iter_mut() }
+ }
+}
+
+impl<'a, 'src> Iterator<(&'a SourceId, &'a mut (Source + 'src))>
+ for SourcesMut<'a, 'src>
+{
+ fn next(&mut self) -> Option<(&'a SourceId, &'a mut (Source + 'src))> {
+ self.inner.next().map(|(a, b)| (a, &mut **b))
}
}
self
}
- pub fn map_dependencies(mut self, f: |Dependency| -> Dependency) -> Summary {
+ pub fn map_dependencies<F>(mut self, f: F) -> Summary
+ where F: FnMut(Dependency) -> Dependency {
let deps = mem::replace(&mut self.dependencies, Vec::new());
self.dependencies = deps.into_iter().map(f).collect();
self
pub use util::{CargoError, CliError, CliResult, human};
-macro_rules! some(
+macro_rules! some {
($e:expr) => (
match $e {
Some(e) => e,
None => return None
}
)
-)
+}
// Added so that the try! macro below can refer to cargo::util, while
// other external importers of this macro can use it as well.
}
#[macro_export]
-macro_rules! try (
+macro_rules! try {
($expr:expr) => ({
use cargo::util::FromError;
match $expr.map_err(FromError::from_error) {
Err(err) => return Err(err)
}
})
-)
+}
-macro_rules! raw_try (
+macro_rules! raw_try {
($expr:expr) => ({
match $expr {
Ok(val) => val,
Err(err) => return Err(err)
}
})
-)
+}
pub mod core;
pub mod ops;
"ar" | "linker" => {
let v = try!(v.string().chain_error(|| {
internal(format!("invalid configuration for key `{}`", k))
- })).ref0().to_string();
+ })).0.to_string();
if k.as_slice() == "linker" {
ret.linker = Some(v);
} else {
internal(format!("invalid configuration for the key \
`target.{}.{}.{}`", triple, lib_name,
k))
- })).val0();
+ })).0;
if k.as_slice() == "rustc-flags" {
let whence = format!("in `target.{}.{}.rustc-flags`",
triple, lib_name);
Some(name) => {
Some(try!(name.string().chain_error(|| {
internal("invalid configuration for key `cargo-new.name`")
- })).ref0().to_string())
+ })).0.to_string())
}
};
cfg.email = match cargo_new.get("email") {
Some(email) => {
Some(try!(email.string().chain_error(|| {
internal("invalid configuration for key `cargo-new.email`")
- })).ref0().to_string())
+ })).0.to_string())
}
};
cfg.git = match cargo_new.get("git") {
Some(git) => {
Some(try!(git.boolean().chain_error(|| {
internal("invalid configuration for key `cargo-new.git`")
- })).val0())
+ })).0)
}
};
)*
}}
}
- lacking!(description, license || license_file, documentation || homepage || repository)
+ lacking!(description, license || license_file, documentation || homepage || repository);
if !missing.is_empty() {
let mut things = missing.slice_to(missing.len() - 1).connect(", ");
dst.display())))
}
- try!(fs::mkdir_recursive(&dst.dir_path(), USER_DIR))
+ try!(fs::mkdir_recursive(&dst.dir_path(), USER_DIR));
let tmpfile = try!(File::create(dst));
//
// Note that this has to do some extra work just before running the command
// to determine extra environment variables and such.
- let work = proc(desc_tx: Sender<String>) {
+ let work = move |: desc_tx: Sender<String>| {
// Make sure that OUT_DIR exists.
//
// If we have an old build directory, then just move it into place,
// Also note that a fresh build command needs to
let (freshness, dirty, fresh) =
try!(fingerprint::prepare_build_cmd(cx, pkg, Some(target)));
- let dirty = proc(tx: Sender<String>) { try!(work(tx.clone())); dirty(tx) };
- let fresh = proc(tx) {
+ let dirty = Work::new(move |tx: Sender<String>| {
+ try!(work(tx.clone()));
+ dirty.call(tx)
+ });
+ let fresh = Work::new(move |tx| {
let (id, pkg_name, build_state, build_output) = all;
let new_loc = build_output.dir_path().join("output");
let mut f = try!(File::open(&new_loc).map_err(|e| {
pkg_name.as_slice()));
build_state.insert(id, req, output);
- fresh(tx)
- };
+ fresh.call(tx)
+ });
Ok((dirty, fresh, freshness))
}
let whence = format!("build script of `{}`", pkg_name);
for line in input.lines() {
- let mut iter = line.splitn(1, |c: char| c == ':');
+ let mut iter = line.splitn(1, |&: c: char| c == ':');
if iter.next() != Some("cargo") {
// skip this line since it doesn't start with "cargo:"
continue;
};
// getting the `key=value` part of the line
- let mut iter = data.splitn(1, |c: char| c == '=');
+ let mut iter = data.splitn(1, |&: c: char| c == '=');
let key = iter.next();
let value = iter.next();
let (key, value) = match (key, value) {
let kind = Kind::Target;
if pkg.get_manifest().get_build().len() == 0 && target.is_none() {
- return Ok((Fresh, proc(_) Ok(()), proc(_) Ok(())))
+ return Ok((Fresh, Work::noop(), Work::noop()));
}
let new = dir(cx, pkg, kind);
let loc = new.join("build");
let new1 = dir(cx, pkg, kind);
let new2 = new1.clone();
- let work1 = proc(_) {
+ let work1 = Work::new(move |_| {
if !new1.exists() {
try!(fs::mkdir(&new1, io::USER_DIR));
}
Ok(())
- };
- let work2 = proc(_) {
+ });
+ let work2 = Work::new(move |_| {
if !new2.exists() {
try!(fs::mkdir(&new2, io::USER_DIR));
}
Ok(())
- };
+ });
(work1, work2)
}
/// Given the data to build and write a fingerprint, generate some Work
/// instances to actually perform the necessary work.
fn prepare(is_fresh: bool, loc: Path, fingerprint: String) -> Preparation {
- let write_fingerprint = proc(desc_tx) {
+ let write_fingerprint = Work::new(move |desc_tx| {
drop(desc_tx);
try!(File::create(&loc).write_str(fingerprint.as_slice()));
Ok(())
- };
+ });
- (if is_fresh {Fresh} else {Dirty}, write_fingerprint, proc(_) Ok(()))
+ (if is_fresh {Fresh} else {Dirty}, write_fingerprint, Work::noop())
}
/// Return the (old, new) location for fingerprints for a package
/// Each proc should send its description before starting.
/// It should send either once or close immediatly.
-pub type Work = proc(Sender<String>):Send -> CargoResult<()>;
+pub struct Work {
+ inner: Box<FnBox<Sender<String>, CargoResult<()>> + Send>,
+}
+
+trait FnBox<A, R> {
+ fn call_box(self: Box<Self>, a: A) -> R;
+}
+
+impl<A, R, F: FnOnce(A) -> R> FnBox<A, R> for F {
+ fn call_box(self: Box<F>, a: A) -> R {
+ (*self)(a)
+ }
+}
+
+impl Work {
+ pub fn new<F>(f: F) -> Work
+ where F: FnOnce(Sender<String>) -> CargoResult<()> + Send {
+ Work { inner: box f }
+ }
+
+ pub fn noop() -> Work {
+ Work::new(|_| Ok(()))
+ }
+
+ pub fn call(self, tx: Sender<String>) -> CargoResult<()> {
+ self.inner.call_box(tx)
+ }
+}
impl Job {
/// Create a new job representing a unit of work.
/// describe itself to the console.
pub fn noop(_dirty: Work,
fresh: Work) -> Job {
- Job { dirty: proc(_) Ok(()), fresh: fresh }
+ Job { dirty: Work::noop(), fresh: fresh }
}
/// Consumes this job by running it, returning the result of the
/// computation.
pub fn run(self, fresh: Freshness, tx: Sender<String>) -> CargoResult<()> {
match fresh {
- Fresh => (self.fresh)(tx),
- Dirty => (self.dirty)(tx),
+ Fresh => self.fresh.call(tx),
+ Dirty => self.dirty.call(tx),
}
}
}
let my_tx = self.tx.clone();
let id = id.clone();
let (desc_tx, desc_rx) = channel();
- self.pool.execute(proc() {
+ self.pool.execute(move|| {
my_tx.send((id, stage, fresh, job.run(fresh, desc_tx)));
});
// only the first message of each job is processed
let (freshness, dirty, fresh) =
try!(fingerprint::prepare_target(cx, pkg, target, kind));
- let dirty = proc(desc_tx: Sender<String>) {
- try!(work(desc_tx.clone()));
- dirty(desc_tx)
- };
+ let dirty = Work::new(move |desc_tx: Sender<String>| {
+ try!(work.call(desc_tx.clone()));
+ dirty.call(desc_tx)
+ });
dst.push((job(dirty, fresh), freshness));
}
1 => pkg.get_manifest().get_build()[0].to_string(),
_ => format!("custom build commands"),
};
- let dirty = proc(desc_tx: Sender<String>) {
+ let dirty = Work::new(move |desc_tx: Sender<String>| {
if desc.len() > 0 {
desc_tx.send_opt(desc).ok();
}
- for cmd in build_cmds.into_iter() { try!(cmd(desc_tx.clone())) }
- dirty(desc_tx)
- };
+ for cmd in build_cmds.into_iter() {
+ try!(cmd.call(desc_tx.clone()))
+ }
+ dirty.call(desc_tx)
+ });
jobs.enqueue(pkg, Stage::BuildCustomBuild, vec![]);
jobs.enqueue(pkg, Stage::RunCustomBuild, vec![(job(dirty, fresh),
freshness)]);
}
let pkg = pkg.to_string();
- Ok(proc(desc_tx: Sender<String>) {
+ Ok(Work::new(move |desc_tx: Sender<String>| {
desc_tx.send_opt(p.to_string()).ok();
if first && !output.exists() {
try!(fs::mkdir(&output, USER_RWX).chain_error(|| {
e.concrete().mark_human()
}));
Ok(())
- })
+ }))
}
fn rustc(package: &Package, target: &Target,
t.is_lib()
});
- Ok((proc(desc_tx: Sender<String>) {
+ Ok((Work::new(move |desc_tx: Sender<String>| {
let mut rustc = rustc;
// Only at runtime have we discovered what the extra -L and -l
Ok(())
- }, kind))
+ }), kind))
}).collect()
}
let primary = package.get_package_id() == cx.resolve.root();
let name = package.get_name().to_string();
let desc = rustdoc.to_string();
- Ok(proc(desc_tx: Sender<String>) {
+ Ok(Work::new(move |desc_tx: Sender<String>| {
desc_tx.send(desc);
if primary {
try!(rustdoc.exec().chain_error(|| {
}))
}
Ok(())
- })
+ }))
}
fn build_base_args(cx: &Context,
Some(index) => {
Some(try!(index.string().chain_error(|| {
internal("invalid configuration for key `index`")
- })).ref0().to_string())
+ })).0.to_string())
}
};
let token = match registry.get("token") {
Some(token) => {
Some(try!(token.string().chain_error(|| {
internal("invalid configuration for key `token`")
- })).ref0().to_string())
+ })).0.to_string())
}
};
Ok(RegistryConfig { index: index, token: token })
Some(proxy) => {
return Ok(Some(try!(proxy.string().chain_error(|| {
internal("invalid configuration for key `http.proxy`")
- })).ref0().to_string()))
+ })).0.to_string()))
}
None => {},
}
let space = String::from_char(
description_margin - name.len(),
' ');
- name + space + desc
+ name.to_string() + space.as_slice() + desc.as_slice()
}
None => name
};
}
impl<'a, 'b> GitSource<'a, 'b> {
- pub fn new<'a, 'b>(source_id: &SourceId,
- config: &'a Config<'b>) -> GitSource<'a, 'b> {
+ pub fn new(source_id: &SourceId,
+ config: &'a Config<'b>) -> GitSource<'a, 'b> {
assert!(source_id.is_git(), "id is not git, id={}", source_id);
let reference = match source_id.git_reference() {
}
impl<'a> GitCheckout<'a> {
- fn new<'a>(path: &Path, database: &'a GitDatabase, revision: GitRevision,
- repo: git2::Repository)
- -> GitCheckout<'a>
+ fn new(path: &Path, database: &'a GitDatabase, revision: GitRevision,
+ repo: git2::Repository)
+ -> GitCheckout<'a>
{
GitCheckout {
location: path.clone(),
}
}
- fn clone_into<'a>(into: &Path, database: &'a GitDatabase,
- revision: GitRevision)
- -> CargoResult<GitCheckout<'a>>
+ fn clone_into(into: &Path, database: &'a GitDatabase,
+ revision: GitRevision)
+ -> CargoResult<GitCheckout<'a>>
{
let repo = try!(GitCheckout::clone_repo(database.get_path(), into));
let checkout = GitCheckout::new(into, database, revision, repo);
}
impl<'a> Config<'a> {
- pub fn new<'a>(shell: &'a mut MultiShell,
- jobs: Option<uint>,
- target: Option<string::String>) -> CargoResult<Config<'a>> {
+ pub fn new(shell: &'a mut MultiShell,
+ jobs: Option<uint>,
+ target: Option<string::String>) -> CargoResult<Config<'a>> {
if jobs == Some(0) {
return Err(human("jobs must be at least 1"))
}
match *self {
CV::String(ref string, _) => string.encode(s),
CV::List(ref list) => {
- let list: Vec<&string::String> = list.iter().map(|s| s.ref0()).collect();
+ let list: Vec<&string::String> = list.iter().map(|s| &s.0).collect();
list.encode(s)
}
CV::Table(ref table) => table.encode(s),
if fresh == Dirty {
self.dirty.insert(dep.clone());
}
- assert!(self.dep_map[*dep].mut0().remove(key));
+ assert!(self.dep_map[*dep].0.remove(key));
}
}
}
}
}
-macro_rules! from_error (
+macro_rules! from_error {
($ty:ty) => {
impl FromError<$ty> for $ty {
fn from_error(error: $ty) -> $ty {
}
}
}
-)
+}
impl Show for Box<CargoError> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
fn description(&self) -> String { self.to_string() }
}
-from_error!(IoError)
+from_error!(IoError);
impl CargoError for TomlError {
fn description(&self) -> String { self.to_string() }
}
-from_error!(TomlError)
+from_error!(TomlError);
impl CargoError for fmt::Error {
fn description(&self) -> String {
}
}
-from_error!(fmt::Error)
+from_error!(fmt::Error);
impl CargoError for curl::ErrCode {
fn description(&self) -> String { self.to_string() }
}
-from_error!(curl::ErrCode)
+from_error!(curl::ErrCode);
impl CargoError for json::DecoderError {
fn description(&self) -> String { self.to_string() }
}
-from_error!(json::DecoderError)
+from_error!(json::DecoderError);
pub struct ProcessError {
pub msg: String,
pub cause: Option<Box<CargoError>>
}
-from_error!(ProcessError)
+from_error!(ProcessError);
impl Show for ProcessError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
}
}
-from_error!(CliError)
+from_error!(CliError);
impl CargoError for docopt::Error {
fn description(&self) -> String {
fn is_human(&self) -> bool { true }
}
-from_error!(docopt::Error)
+from_error!(docopt::Error);
impl CargoError for url::ParseError {
fn description(&self) -> String { self.to_string() }
}
-from_error!(url::ParseError)
+from_error!(url::ParseError);
impl CargoError for git2::Error {
fn description(&self) -> String { self.to_string() }
}
-from_error!(git2::Error)
+from_error!(git2::Error);
impl CliError {
pub fn new<S: Str>(error: S, code: uint) -> CliError {
use time;
use std::cell::RefCell;
-thread_local!(static PROFILE_STACK: RefCell<Vec<u64>> = RefCell::new(Vec::new()))
-thread_local!(static MESSAGES: RefCell<Vec<Message>> = RefCell::new(Vec::new()))
+thread_local!(static PROFILE_STACK: RefCell<Vec<u64>> = RefCell::new(Vec::new()));
+thread_local!(static MESSAGES: RefCell<Vec<Message>> = RefCell::new(Vec::new()));
type Message = (uint, u64, String);
fn CryptDestroyHash(hHash: HCRYPTHASH) -> BOOL;
}
- macro_rules! call( ($e:expr) => ({
+ macro_rules! call{ ($e:expr) => ({
if $e == 0 {
panic!("failed {}: {}", stringify!($e), os::last_os_error())
}
- }) )
+ }) }
pub struct Sha256 {
hcryptprov: HCRYPTPROV,
add_unused_keys(m, v, if key.len() == 0 {
k.clone()
} else {
- key + "." + k.as_slice()
+ key.clone() + "." + k.as_slice()
})
}
}
+2014-12-20
+ linux-i386 1cccab5a6ac8e73472bf78cdce019cd1a60d4638
+ linux-x86_64 53c176fcda0a40fb77b901303c443de3dce3e58d
+ macos-i386 bbc23c78ca4307efa6250552a097e6b2ccfe2cc3
+ macos-x86_64 4f97a30408c99858ad2b7a7f6edfe3d5b8f0ff3f
+ winnt-i386 5d77cd604b011100398023e8dc3d98c173247874
+ winnt-x86_64 1290dcc2a51e99027803d641c08299abe1265158
+
2014-12-18
linux-i386 30eec547395093ab9c6a0587a3210666b9272815
linux-x86_64 20d13252996838680f4356a7addd75403bb11aec
}
}
-macro_rules! pkg(
+macro_rules! pkg {
($pkgid:expr => [$($deps:expr),+]) => ({
let d: Vec<Dependency> = vec![$($deps.to_dep()),+];
($pkgid:expr) => (
Summary::new($pkgid.to_pkgid(), Vec::new(), HashMap::new()).unwrap()
)
-)
+}
fn registry_loc() -> SourceId {
let remote = "http://example.com".to_url().unwrap();
static CARGO_INTEGRATION_TEST_DIR : &'static str = "cit";
static NEXT_ID: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
-thread_local!(static TASK_ID: uint = NEXT_ID.fetch_add(1, atomic::SeqCst))
+thread_local!(static TASK_ID: uint = NEXT_ID.fetch_add(1, atomic::SeqCst));
pub fn root() -> Path {
let path = os::self_exe_path().unwrap()
let output = output.exec_with_output().assert();
let output = str::from_utf8(output.output.as_slice()).assert();
assert!(output.contains("\n 1\n"), "missing 1: {}", output);
-})
+});
test!(find_closest_biuld_to_build {
let pr = process(cargo_dir().join("cargo")).unwrap()
Did you mean `build`?
"));
-})
+});
// if a subcommand is more than 3 edit distance away, we don't make a suggestion
test!(find_closest_dont_correct_nonsense {
execs().with_status(127)
.with_stderr("No such subcommand
"));
-})
+});
",
COMPILING, p.url(),
RUNNING)));
-})
+});
test!(bench_target_name {
let prj = project("foo")
assert_that(prj.cargo_process("bench").arg("--bench").arg("bin2"),
execs().with_status(0).with_stdout(expected_stdout.as_slice()));
-})
+});
test!(cargo_bench_verbose {
let p = project("foo")
",
compiling = COMPILING, url = p.url(), running = RUNNING)));
-})
+});
test!(many_similar_names {
let p = project("foo")
assert!(output.contains("test bin_bench"), "bin_bench missing\n{}", output);
assert!(output.contains("test lib_bench"), "lib_bench missing\n{}", output);
assert!(output.contains("test bench_bench"), "bench_bench missing\n{}", output);
-})
+});
test!(cargo_bench_failing_test {
let p = project("foo")
`hello`, right: `nope`)', src{sep}foo.rs:13
", sep = path::SEP))
.with_status(101));
-})
+});
test!(bench_with_lib_dep {
let p = project("foo")
",
COMPILING, p.url(), running = RUNNING)))
-})
+});
test!(bench_with_deep_lib_dep {
let p = project("bar")
",
compiling = COMPILING, running = RUNNING,
dir = p.url()).as_slice()));
-})
+});
test!(external_bench_explicit {
let p = project("foo")
",
COMPILING, p.url(), running = RUNNING)))
-})
+});
test!(external_bench_implicit {
let p = project("foo")
",
COMPILING, p.url(), running = RUNNING)))
-})
+});
test!(dont_run_examples {
let p = project("foo")
"#);
assert_that(p.cargo_process("bench"),
execs().with_status(0));
-})
+});
test!(pass_through_command_line {
let p = project("foo")
",
compiling = COMPILING, running = RUNNING,
dir = p.url()).as_slice()));
-})
+});
// Regression test for running cargo-bench twice with
// tests in an rlib
assert_that(p.process(cargo_dir().join("cargo")).arg("bench"),
execs().with_status(0));
}
-})
+});
test!(lib_bin_same_name {
let p = project("foo")
",
COMPILING, p.url(), running = RUNNING)))
-})
+});
test!(lib_with_standard_name {
let p = project("foo")
",
compiling = COMPILING, running = RUNNING,
dir = p.url()).as_slice()));
-})
+});
test!(lib_with_standard_name2 {
let p = project("foo")
",
compiling = COMPILING, running = RUNNING,
dir = p.url()).as_slice()));
-})
+});
test!(bin_there_for_integration {
let p = project("foo")
assert!(output.contains("bench_bench ... bench: 0 ns/iter (+/- 0)"),
"no bench_bench\n{}",
output);
-})
+});
#[cfg(not(windows))] // FIXME(#456)
test!(bench_dylib {
",
fresh = FRESH, running = RUNNING,
dir = p.url()).as_slice()));
-})
+});
test!(bench_twice_with_build_cmd {
let p = project("foo")
",
running = RUNNING)));
-})
+});
.collect()
}
- spawn(proc() {
+ spawn(move|| {
let mut s = BufferedStream::new(a.accept().unwrap());
let req = headers(&mut s);
s.write(b"\
addr = addr)));
rx.recv();
-})
+});
// Boy, sure would be nice to have a TLS implementation in rust!
test!(https_something_happens {
let a2 = a.clone();
let _c = Closer { a: a2 };
let (tx, rx) = channel();
- spawn(proc() {
+ spawn(move|| {
drop(a.accept().unwrap());
tx.send(());
})));
rx.recv();
-})
+});
// Boy, sure would be nice to have an SSH implementation in rust!
test!(ssh_something_happens {
let a2 = a.clone();
let _c = Closer { a: a2 };
let (tx, rx) = channel();
- spawn(proc() {
+ spawn(move|| {
drop(a.accept().unwrap());
tx.send(());
addr = addr)));
rx.recv();
-})
+});
execs()
.with_status(0)
.with_stdout(verbose_output_for_lib(&p)));
-})
+});
test!(build_with_no_lib {
execs()
.with_status(101)
.with_stderr("There is no lib to build, remove `--lib` flag"));
-})
+});
assert_that(p.process(cargo_dir().join("cargo")).arg("clean"),
execs().with_status(0));
assert_that(&p.build_dir(), is_not(existing_dir()));
-})
+});
test!(different_dir {
let p = project("foo")
.cwd(p.root().join("src")),
execs().with_status(0).with_stdout(""));
assert_that(&p.build_dir(), is_not(existing_dir()));
-})
+});
assert_that(
process(p.bin("foo")).unwrap(),
execs().with_stdout("i am foo\n"));
-})
+});
test!(cargo_compile_manifest_path {
let p = project("foo")
.cwd(p.root().dir_path()),
execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
-})
+});
test!(cargo_compile_with_invalid_manifest {
let p = project("foo")
.with_status(101)
.with_stderr("Cargo.toml is not a valid manifest\n\n\
No `package` or `project` section found.\n"))
-})
+});
test!(cargo_compile_with_invalid_manifest2 {
let p = project("foo")
.with_status(101)
.with_stderr("could not parse input TOML\n\
Cargo.toml:3:19-3:20 expected a value\n\n"))
-})
+});
test!(cargo_compile_with_invalid_manifest3 {
let p = project("foo")
.with_status(101)
.with_stderr("could not parse input TOML\n\
src[..]Cargo.toml:1:5-1:6 expected a value\n\n"))
-})
+});
test!(cargo_compile_with_invalid_version {
let p = project("foo")
cannot parse '1.0' as a semver for the key \
`project.version`\n"))
-})
+});
test!(cargo_compile_without_manifest {
let tmpdir = TempDir::new("cargo").unwrap();
.with_status(102)
.with_stderr("Could not find Cargo.toml in this directory or any \
parent directory\n"));
-})
+});
test!(cargo_compile_with_invalid_code {
let p = project("foo")
To learn more, run the command again with --verbose.\n",
filename = format!("src{}foo.rs", path::SEP)).as_slice()));
assert_that(&p.root().join("Cargo.lock"), existing_file());
-})
+});
test!(cargo_compile_with_invalid_code_in_deps {
let p = project("foo")
bar.build();
baz.build();
assert_that(p.cargo_process("build"), execs().with_status(101));
-})
+});
test!(cargo_compile_with_warnings_in_the_root_package {
let p = project("foo")
{filename}:1 fn main() {{}} fn dead() {{}}
^~~~~~~~~~~~
", filename = format!("src{}foo.rs", path::SEP).as_slice())));
-})
+});
test!(cargo_compile_with_warnings_in_a_dep_package {
let mut p = project("foo");
assert_that(
process(p.bin("foo")).unwrap(),
execs().with_stdout("test passed\n"));
-})
+});
test!(cargo_compile_with_nested_deps_inferred {
let p = project("foo")
assert_that(
process(p.bin("foo")).unwrap(),
execs().with_stdout("test passed\n"));
-})
+});
test!(cargo_compile_with_nested_deps_correct_bin {
let p = project("foo")
assert_that(
process(p.bin("foo")).unwrap(),
execs().with_stdout("test passed\n"));
-})
+});
test!(cargo_compile_with_nested_deps_shorthand {
let p = project("foo")
assert_that(
process(p.bin("foo")).unwrap(),
execs().with_stdout("test passed\n"));
-})
+});
test!(cargo_compile_with_nested_deps_longhand {
let p = project("foo")
assert_that(
process(p.bin("foo")).unwrap(),
execs().with_stdout("test passed\n"));
-})
+});
// Check that Cargo gives a sensible error if a dependency can't be found
// because of a name mismatch.
location searched: {proj_dir}
version required: *
"#, proj_dir = p.url())));
-})
+});
// test!(compiling_project_with_invalid_manifest)
assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_status(0));
-})
+});
// this is testing that src/<pkg-name>.rs still works (for now)
test!(many_crate_types_old_style_lib_location {
assert!(file0.ends_with(".rlib") || file1.ends_with(".rlib"));
assert!(file0.ends_with(os::consts::DLL_SUFFIX) ||
file1.ends_with(os::consts::DLL_SUFFIX));
-})
+});
test!(many_crate_types_correct {
let mut p = project("foo");
assert!(file0.ends_with(".rlib") || file1.ends_with(".rlib"));
assert!(file0.ends_with(os::consts::DLL_SUFFIX) ||
file1.ends_with(os::consts::DLL_SUFFIX));
-})
+});
test!(unused_keys {
let mut p = project("foo");
assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stderr("unused manifest key: lib.build\n"));
-})
+});
test!(self_dependency {
let mut p = project("foo");
.file("src/test.rs", "fn main() {}");
assert_that(p.cargo_process("build"),
execs().with_status(0));
-})
+});
#[cfg(not(windows))]
test!(ignore_broken_symlinks {
assert_that(
process(p.bin("foo")).unwrap(),
execs().with_stdout("i am foo\n"));
-})
+});
test!(missing_lib_and_bin {
let mut p = project("foo");
execs().with_status(101)
.with_stderr("either a [lib] or [[bin]] section \
must be present\n"));
-})
+});
test!(lto_build {
let mut p = project("foo");
dir = p.root().display(),
url = p.url(),
)));
-})
+});
test!(verbose_build {
let mut p = project("foo");
dir = p.root().display(),
url = p.url(),
)));
-})
+});
test!(verbose_release_build {
let mut p = project("foo");
dir = p.root().display(),
url = p.url(),
)));
-})
+});
test!(verbose_release_build_deps {
let mut p = project("foo");
sep = path::SEP,
prefix = os::consts::DLL_PREFIX,
suffix = os::consts::DLL_SUFFIX).as_slice()));
-})
+});
test!(explicit_examples {
let mut p = project("world");
execs().with_stdout("Hello, World!\n"));
assert_that(process(p.bin("examples/goodbye")).unwrap(),
execs().with_stdout("Goodbye, World!\n"));
-})
+});
test!(implicit_examples {
let mut p = project("world");
execs().with_stdout("Hello, World!\n"));
assert_that(process(p.bin("examples/goodbye")).unwrap(),
execs().with_stdout("Goodbye, World!\n"));
-})
+});
test!(standard_build_no_ndebug {
let p = project("world")
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(p.bin("foo")).unwrap(), execs().with_stdout("slow\n"));
-})
+});
test!(release_build_ndebug {
let p = project("world")
assert_that(p.cargo_process("build").arg("--release"),
execs().with_status(0));
assert_that(process(p.bin("release/foo")).unwrap(), execs().with_stdout("fast\n"));
-})
+});
test!(inferred_main_bin {
let p = project("world")
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(p.bin("foo")).unwrap(), execs().with_status(0));
-})
+});
test!(deletion_causes_failure {
let p = project("foo")
authors = []
"#);
assert_that(p.cargo_process("build"), execs().with_status(101));
-})
+});
test!(bad_cargo_toml_in_target_dir {
let p = project("world")
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(p.bin("foo")).unwrap(), execs().with_status(0));
-})
+});
test!(lib_with_standard_name {
let p = project("foo")
",
compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
test!(simple_staticlib {
let p = project("foo")
.file("src/lib.rs", "pub fn foo() {}");
assert_that(p.cargo_process("build"), execs().with_status(0));
-})
+});
test!(staticlib_rlib_and_bin {
let p = project("foo")
}"#);
assert_that(p.cargo_process("build"), execs().with_status(0));
-})
+});
test!(opt_out_of_lib {
let p = project("foo")
.file("src/lib.rs", "bad syntax")
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("build"), execs().with_status(0));
-})
+});
test!(opt_out_of_bin {
let p = project("foo")
.file("src/lib.rs", "")
.file("src/main.rs", "bad syntax");
assert_that(p.cargo_process("build"), execs().with_status(0));
-})
+});
test!(single_lib {
let p = project("foo")
"#)
.file("src/bar.rs", "");
assert_that(p.cargo_process("build"), execs().with_status(0));
-})
+});
test!(deprecated_lib {
let p = project("foo")
execs().with_status(0)
.with_stderr("\
the [[lib]] section has been deprecated in favor of [lib]\n"));
-})
+});
test!(freshness_ignores_excluded {
let foo = project("foo")
assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(""));
-})
+});
test!(rebuild_preserves_out_dir {
let mut build = project("builder");
.with_stdout(format!("\
{compiling} foo v0.0.0 ({url})
", compiling = COMPILING, url = foo.url())));
-})
+});
test!(dep_no_libs {
let foo = project("foo")
execs().with_status(101)
.with_stderr("\
Package `bar v0.0.0 ([..])` has no library targets"));
-})
+});
test!(recompile_space_in_name {
let foo = project("foo")
foo.root().move_into_the_past().assert();
assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(""));
-})
+});
test!(ignore_bad_directories {
let foo = project("foo")
assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0));
fs::chmod(&foo.root().join("tmp"), io::USER_DIR).unwrap();
-})
+});
test!(bad_cargo_config {
let foo = project("foo")
[..].cargo[..]config:2:20-2:21 expected `=`, but found `i`
"));
-})
+});
#[cfg(target_os = "linux")]
test!(cargo_platform_specific_dependency {
assert_that(
process(p.bin("foo")).unwrap(),
execs().with_stdout("test passed\n"));
-})
+});
#[cfg(not(target_os = "linux"))]
test!(cargo_platform_specific_dependency {
assert_that(p.cargo_process("build"),
execs().with_status(101));
-})
+});
test!(cargo_platform_specific_dependency_wrong_platform {
let p = project("foo")
let lockfile = p.root().join("Cargo.lock");
let lockfile = File::open(&lockfile).read_to_string().assert();
assert!(lockfile.as_slice().contains("bar"))
-})
+});
test!(example_bin_same_name {
let p = project("foo")
assert_that(&p.bin("foo"), existing_file());
assert_that(&p.bin("examples/foo"), existing_file());
-})
+});
test!(compile_then_delete {
let p = project("foo")
fs::unlink(&p.bin("foo")).unwrap();
assert_that(p.process(cargo_dir().join("cargo")).arg("run"),
execs().with_status(0));
-})
+});
Failed to run custom build command for `foo v0.5.0 ({})`
Process didn't exit successfully: `[..]build[..]build-script-build[..]` (status=101)",
p.url())));
-})
+});
test!(custom_build_env_vars {
let p = project("foo")
assert_that(p.cargo_process("build").arg("--features").arg("bar_feat"),
execs().with_status(0));
-})
+});
test!(custom_build_script_wrong_rustc_flags {
let p = project("foo")
Only `-l` and `-L` flags are allowed in build script of `foo v0.5.0 ({})`: \
`-aaa -bbb`",
p.url())));
-})
+});
/*
test!(custom_build_script_rustc_flags {
dir = p.root().display(),
url = p.url(),
)));
-})
+});
*/
test!(links_no_build_cmd {
package `foo v0.5.0 (file://[..])` specifies that it links to `a` but does \
not have a custom build script
"));
-})
+});
test!(links_duplicates {
let p = project("foo")
[..] v0.5.0 (file://[..])
[..] v0.5.0 (file://[..])
"));
-})
+});
test!(overrides_and_links {
let (_, target) = ::cargo::ops::rustc_version().unwrap();
[..]
{running} `rustc [..] --crate-name foo [..] -L foo -L bar[..]`
", running = RUNNING).as_slice()));
-})
+});
test!(unused_overrides {
let (_, target) = ::cargo::ops::rustc_version().unwrap();
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-})
+});
test!(links_passes_env_vars {
let p = project("foo")
{running} `[..]`
{running} `rustc [..] --crate-name foo [..]`
", compiling = COMPILING, running = RUNNING).as_slice()));
-})
+});
test!(only_rerun_build_script {
let p = project("foo")
{running} `[..]build-script-build[..]`
{running} `rustc [..] --crate-name foo [..]`
", compiling = COMPILING, running = RUNNING).as_slice()));
-})
+});
test!(rebuild_continues_to_pass_env_vars {
let a = project("a")
assert_that(p.process(cargo_dir().join("cargo")).arg("build").arg("-v"),
execs().with_status(0));
-})
+});
test!(testing_and_such {
let p = project("foo")
{compiling} foo v0.5.0 (file://[..])
{running} `target[..]foo`
", compiling = COMPILING, running = RUNNING).as_slice()));
-})
+});
test!(propagation_of_l_flags {
let (_, target) = ::cargo::ops::rustc_version().unwrap();
{compiling} foo v0.5.0 (file://[..])
{running} `rustc [..] --crate-name foo [..] -L bar -L foo`
", compiling = COMPILING, running = RUNNING).as_slice()));
-})
+});
test!(build_deps_simple {
let p = project("foo")
{running} `[..]foo-[..]build-script-build[..]`
{running} `rustc [..] --crate-name foo [..]`
", compiling = COMPILING, running = RUNNING).as_slice()));
-})
+});
test!(build_deps_not_for_normal {
let (_, target) = ::cargo::ops::rustc_version().unwrap();
Caused by:
Process didn't exit successfully: [..]
"));
-})
+});
test!(build_cmd_with_a_build_cmd {
let p = project("foo")
--out-dir [..]target --dep-info [..]fingerprint[..]dep-lib-foo \
-L [..]target -L [..]target[..]deps`
", compiling = COMPILING, running = RUNNING).as_slice()));
-})
+});
test!(out_dir_is_preserved {
let p = project("foo")
File::create(&p.root().join("foo")).unwrap();
assert_that(p.process(cargo_dir().join("cargo")).arg("build").arg("-v"),
execs().with_status(0));
-})
+});
test!(output_separate_lines {
let p = project("foo")
{running} `[..]foo-[..]build-script-build[..]`
{running} `rustc [..] --crate-name foo [..] -L foo -l foo:static`
", compiling = COMPILING, running = RUNNING).as_slice()));
-})
+});
#[cfg(not(windows))] // FIXME(#867)
test!(code_generation {
build = "build.rs"
"#)
.file("src/main.rs", r#"
- include!(concat!(env!("OUT_DIR"), "/hello.rs"))
+ include!(concat!(env!("OUT_DIR"), "/hello.rs"));
fn main() {
println!("{}", message());
assert_that(p.cargo_process("test"),
execs().with_status(0));
-})
+});
test!(release_with_build_script {
let p = project("foo")
assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0));
-})
+});
test!(build_script_only {
let p = project("foo")
execs().with_status(101)
.with_stderr("either a [lib] or [[bin]] section must \
be present"));
-})
+});
test!(shared_dep_with_a_build_script {
let p = project("foo")
.file("b/src/lib.rs", "");
assert_that(p.cargo_process("build"),
execs().with_status(0));
-})
+});
test!(transitive_dep_host {
let p = project("foo")
.file("b/src/lib.rs", "");
assert_that(p.cargo_process("build"),
execs().with_status(0));
-})
+});
test!(test_a_lib_with_a_build_command {
let p = project("foo")
build = "build.rs"
"#)
.file("src/lib.rs", r#"
- include!(concat!(env!("OUT_DIR"), "/foo.rs"))
+ include!(concat!(env!("OUT_DIR"), "/foo.rs"));
/// ```
/// foo::bar();
"#);
assert_that(p.cargo_process("test"),
execs().with_status(0));
-})
+});
test!(test_dev_dep_build_script {
let p = project("foo")
.file("a/src/lib.rs", "");
assert_that(p.cargo_process("test"), execs().with_status(0));
-})
+});
assert_that(
cargo::util::process(project.bin("foo")).unwrap(),
execs().with_stdout("hello world\n"));
-})
+});
test!(cargo_compile_git_dep_branch {
let project = project("foo");
assert_that(
cargo::util::process(project.bin("foo")).unwrap(),
execs().with_stdout("hello world\n"));
-})
+});
test!(cargo_compile_git_dep_tag {
let project = project("foo");
assert_that(
cargo::util::process(project.bin("foo")).unwrap(),
execs().with_stdout("hello world\n"));
-})
+});
test!(cargo_compile_with_nested_paths {
let git_project = git_repo("dep1", |project| {
assert_that(
cargo::util::process(p.bin("parent")).unwrap(),
execs().with_stdout("hello world\n"));
-})
+});
test!(cargo_compile_with_meta_package {
let git_project = git_repo("meta-dep", |project| {
assert_that(
cargo::util::process(p.bin("parent")).unwrap(),
execs().with_stdout("this is dep1 this is dep2\n"));
-})
+});
test!(cargo_compile_with_short_ssh_git {
let url = "git@github.com:a/dep";
.with_stdout("")
.with_stderr(format!("Cargo.toml is not a valid manifest\n\n\
invalid url `{}`: relative URL without a base\n", url)));
-})
+});
test!(two_revs_same_deps {
let bar = git_repo("meta-dep", |project| {
execs().with_status(0));
assert_that(&foo.bin("foo"), existing_file());
assert_that(foo.process(foo.bin("foo")), execs().with_status(0));
-})
+});
test!(recompilation {
let git_project = git_repo("bar", |project| {
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} foo v0.5.0 ({})\n",
COMPILING, p.url())));
-})
+});
test!(update_with_shared_deps {
let git_project = git_repo("bar", |project| {
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
-})
+});
test!(dep_with_submodule {
let project = project("foo");
assert_that(project.cargo_process("build"),
execs().with_stderr("").with_status(0));
-})
+});
test!(two_deps_only_update_one {
let project = project("foo");
.with_stdout(format!("{} git repository `{}`\n",
UPDATING, git1.url()))
.with_stderr(""));
-})
+});
test!(stale_cached_version {
let bar = git_repo("meta-dep", |project| {
{compiling} foo v0.0.0 ({foo})
", updating = UPDATING, compiling = COMPILING, bar = bar.url(), foo = foo.url())));
assert_that(foo.process(foo.bin("foo")), execs().with_status(0));
-})
+});
test!(dep_with_changed_submodule {
let project = project("foo");
compiling = COMPILING, running = RUNNING))
.with_stderr("")
.with_status(0));
-})
+});
test!(dev_deps_with_testing {
let p2 = git_repo("bar", |project| {
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
", compiling = COMPILING, running = RUNNING)));
-})
+});
test!(git_build_cmd_freshness {
let foo = git_repo("foo", |project| {
assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(""));
-})
+});
test!(git_name_not_always_needed {
let p2 = git_repo("bar", |project| {
{updating} git repository `{bar}`
{compiling} foo v0.5.0 ({url})
", updating = UPDATING, compiling = COMPILING, url = p.url(), bar = p2.url())));
-})
+});
test!(git_repo_changing_no_rebuild {
let bar = git_repo("bar", |project| {
// even though the git repo has changed.
assert_that(p1.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(""));
-})
+});
test!(git_dep_build_cmd {
let p = git_repo("foo", |project| {
assert_that(
cargo::util::process(p.bin("foo")).unwrap(),
execs().with_stdout("1\n"));
-})
+});
test!(fetch_downloads {
let bar = git_repo("bar", |project| {
assert_that(p.process(cargo_dir().join("cargo")).arg("fetch"),
execs().with_status(0).with_stdout(""));
-})
+});
test!(warnings_in_git_dep {
let bar = git_repo("bar", |project| {
COMPILING, bar.url(),
COMPILING, p.url()))
.with_stderr(""));
-})
+});
test!(update_ambiguous {
let foo1 = git_repo("foo1", |project| {
foo:0.[..].0
foo:0.[..].0
"));
-})
+});
test!(update_one_dep_in_repo_with_many_deps {
let foo = git_repo("foo", |project| {
.with_stdout(format!("\
Updating git repository `{}`
", foo.url())));
-})
+});
test!(switch_deps_does_not_update_transitive {
let transitive = git_repo("transitive", |project| {
{compiling} dep [..]
{compiling} project [..]
", dep2.url(), compiling = COMPILING)));
-})
+});
test!(update_one_source_updates_all_packages_in_that_git_source {
let dep = git_repo("dep", |project| {
.unwrap();
assert!(!lockfile.as_slice().contains(rev1.to_string().as_slice()),
"{} in {}", rev1, lockfile);
-})
+});
test!(switch_sources {
let a1 = git_repo("a1", |project| {
{compiling} b v0.5.0 ([..])
{compiling} project v0.5.0 ([..])
", updating = UPDATING, compiling = COMPILING).as_slice()));
-})
+});
.with_stderr("warning: [..] deprecated.\n\
[..]\n\
[..]"));
-})
+});
test!(old_custom_multiple_build {
let mut build1 = project("builder1");
execs().with_status(0)
.with_stdout(format!(" Compiling foo v0.5.0 ({})\n",
p.url())));
-})
+});
test!(old_custom_build_failure {
let mut build = project("builder");
\n\
", build.bin("foo").display(), filename = format!("src{}foo.rs", path::SEP),
dir = p.url())));
-})
+});
test!(old_custom_second_build_failure {
let mut build1 = project("builder1");
\n\
", build2.bin("bar").display(), filename = format!("src{}bar.rs", path::SEP),
dir = p.url())));
-})
+});
test!(old_custom_build_env_vars {
let bar = project("bar")
"#);
assert_that(p.cargo_process("build").arg("--features").arg("foo"),
execs().with_status(0));
-})
+});
test!(old_custom_build_in_dependency {
let mut p = project("foo");
"#);
assert_that(p.cargo_process("build"),
execs().with_status(0));
-})
+});
// tests that custom build in dep can be built twice in a row - issue 227
test!(old_custom_build_in_dependency_twice {
execs().with_status(0));
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0));
-})
+});
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
-})
+});
test!(cargo_compile_with_root_dev_deps {
let p = project("foo")
p2.build();
assert_that(p.cargo_process("build"),
execs().with_status(101))
-})
+});
test!(cargo_compile_with_root_dev_deps_with_testing {
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
", compiling = COMPILING, url = p.url(), running = RUNNING)));
-})
+});
test!(cargo_compile_with_transitive_dev_deps {
let p = project("foo")
assert_that(
cargo::util::process(p.bin("foo")).unwrap(),
execs().with_stdout("zoidberg\n"));
-})
+});
test!(no_rebuild_dependency {
let mut p = project("foo");
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
-})
+});
test!(deep_dependencies_trigger_rebuild {
let mut p = project("foo");
COMPILING, p.url(),
COMPILING, p.url())));
-})
+});
test!(no_rebuild_two_deps {
let mut p = project("foo");
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(""));
assert_that(&p.bin("foo"), existing_file());
-})
+});
test!(nested_deps_recompile {
let p = project("foo")
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} foo v0.5.0 ({})\n",
COMPILING, p.url())));
-})
+});
test!(error_message_for_missing_manifest {
let p = project("foo")
.with_stderr(format!("Could not find `Cargo.toml` in `{}`\n",
p.root().join_many(&["src", "bar"]).display())));
-})
+});
test!(override_relative {
let bar = project("bar")
bar.build();
assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
-})
+});
test!(override_self {
let bar = project("bar")
bar.build();
assert_that(p.cargo_process("build"), execs().with_status(0));
-})
+});
test!(override_path_dep {
let bar = project("bar")
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
-})
+});
test!(path_dep_build_cmd {
let p = project("foo")
assert_that(
cargo::util::process(p.bin("foo")).unwrap(),
execs().with_stdout("1\n"));
-})
+});
test!(dev_deps_no_rebuild_lib {
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
", COMPILING, p.url(), COMPILING, p.url())));
-})
+});
execs().with_status(0));
assert_that(foo.process(cargo_dir().join("cargo")).arg("doc"),
execs().with_status(0));
-})
+});
test!(plugin_with_dynamic_native_dependency {
let build = project("builder")
assert_that(foo.cargo_process("build").env("SRC", Some(lib.as_vec())),
execs().with_status(0));
-})
+});
assert_that(
process(p.target_bin(target, "foo")).unwrap(),
execs().with_status(0));
-})
+});
test!(simple_deps {
if disabled() { return }
assert_that(
process(p.target_bin(target, "foo")).unwrap(),
execs().with_status(0));
-})
+});
test!(plugin_deps {
if disabled() { return }
assert_that(
process(foo.target_bin(target, "foo")).unwrap(),
execs().with_status(0));
-})
+});
test!(plugin_to_the_max {
if disabled() { return }
assert_that(
process(foo.target_bin(target, "foo")).unwrap(),
execs().with_status(0));
-})
+});
test!(linker_and_ar {
if disabled() { return }
target = target,
sep = path::SEP,
).as_slice()));
-})
+});
test!(plugin_with_extra_dylib_dep {
if disabled() { return }
let target = alternate();
assert_that(foo.cargo_process("build").arg("--target").arg(target),
execs().with_status(0));
-})
+});
test!(cross_tests {
if disabled() { return }
", compiling = COMPILING, running = RUNNING, foo = p.url(), triple = target,
doctest = DOCTEST)));
-})
+});
test!(simple_cargo_run {
if disabled() { return }
let target = alternate();
assert_that(p.cargo_process("run").arg("--target").arg(target),
execs().with_status(0));
-})
+});
test!(cross_but_no_dylibs {
let p = project("foo")
execs().with_status(101)
.with_stderr("dylib outputs are not supported for \
arm-apple-ios"));
-})
+});
test!(cross_with_a_build_script {
if disabled() { return }
{running} `rustc {dir}{sep}src{sep}main.rs [..] --target {target} [..]`
", compiling = COMPILING, running = RUNNING, target = target,
dir = p.root().display(), sep = path::SEP).as_slice()));
-})
+});
test!(build_script_needed_for_host_and_target {
if disabled() { return }
-L /path/to/{target}`
", compiling = COMPILING, running = RUNNING, target = target, host = host,
dir = p.root().display(), sep = path::SEP).as_slice()));
-})
+});
test!(build_deps_for_the_right_arch {
if disabled() { return }
let target = alternate();
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
-})
+});
test!(build_script_only_host {
if disabled() { return }
let target = alternate();
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
-})
+});
dir = path2url(p.root())).as_slice()));
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
-})
+});
test!(doc_no_libs {
let p = project("foo")
assert_that(p.cargo_process("doc"),
execs().with_status(0));
-})
+});
test!(doc_twice {
let p = project("foo")
assert_that(p.process(cargo_dir().join("cargo")).arg("doc"),
execs().with_status(0).with_stdout(""))
-})
+});
test!(doc_deps {
let p = project("foo")
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
-})
+});
test!(doc_no_deps {
let p = project("foo")
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/index.html"), is_not(existing_file()));
-})
+});
test!(doc_only_bin {
let p = project("foo")
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
-})
+});
test!(doc_lib_bin_same_name {
let p = project("foo")
Cannot document a package where a library and a binary have the same name. \
Consider renaming one or marking the target as `doc = false`
"));
-})
+});
test!(doc_dash_p {
let p = project("foo")
{compiling} b v0.0.1 (file://[..])
{compiling} a v0.0.1 (file://[..])
", compiling = COMPILING).as_slice()));
-})
+});
Feature `bar` includes `baz` which is neither a dependency nor another feature
").as_slice()));
-})
+});
test!(invalid2 {
let p = project("foo")
Features and dependencies cannot have the same name: `bar`
").as_slice()));
-})
+});
test!(invalid3 {
let p = project("foo")
Feature `bar` depends on `baz` which is not an optional dependency.
Consider adding `optional = true` to the dependency
").as_slice()));
-})
+});
test!(invalid4 {
let p = project("foo")
execs().with_status(101).with_stderr(format!("\
Package `foo v0.0.1 ([..])` does not have these features: `test`
").as_slice()));
-})
+});
test!(invalid5 {
let p = project("foo")
Dev-dependencies are not allowed to be optional: `bar`
").as_slice()));
-})
+});
test!(invalid6 {
let p = project("foo")
Feature `foo` requires `bar` which is not an optional dependency
").as_slice()));
-})
+});
test!(invalid7 {
let p = project("foo")
Feature `foo` requires `bar` which is not an optional dependency
").as_slice()));
-})
+});
test!(invalid8 {
let p = project("foo")
execs().with_status(101).with_stderr(format!("\
features in dependencies cannot enable features in other dependencies: `foo/bar`
").as_slice()));
-})
+});
test!(no_feature_doesnt_build {
let p = project("foo")
", compiling = COMPILING, dir = p.url()).as_slice()));
assert_that(p.process(p.bin("foo")),
execs().with_status(0).with_stdout("bar\n"));
-})
+});
test!(default_feature_pulled_in {
let p = project("foo")
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url()).as_slice()));
assert_that(p.process(p.bin("foo")), execs().with_status(0).with_stdout(""));
-})
+});
test!(cyclic_feature {
let p = project("foo")
execs().with_status(101).with_stderr("\
Cyclic feature dependency: feature `default` depends on itself
"));
-})
+});
test!(cyclic_feature2 {
let p = project("foo")
execs().with_status(101).with_stderr("\
Cyclic feature dependency: feature `[..]` depends on itself
"));
-})
+});
test!(groups_on_groups_on_groups {
let p = project("foo")
{compiling} ba[..] v0.0.1 ({dir})
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url()).as_slice()));
-})
+});
test!(many_cli_features {
let p = project("foo")
{compiling} ba[..] v0.0.1 ({dir})
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url()).as_slice()));
-})
+});
test!(union_features {
let p = project("foo")
{compiling} d1 v0.0.1 ({dir})
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url()).as_slice()));
-})
+});
test!(many_features_no_rebuilds {
let p = project("foo")
{fresh} a v0.1.0 ([..])
{fresh} b v0.1.0 ([..])
", fresh = FRESH).as_slice()));
-})
+});
// Tests that all cmd lines work with `--features ""`
test!(empty_features {
assert_that(p.cargo_process("build").arg("--features").arg(""),
execs().with_status(0));
-})
+});
// Tests that all cmd lines work with `--features ""`
test!(transitive_features {
assert_that(p.cargo_process("build").arg("--features").arg("foo"),
execs().with_status(0));
-})
+});
test!(everything_in_the_lockfile {
let p = project("foo")
assert!(lockfile.contains(r#"name = "d1""#), "d1 not found\n{}", lockfile);
assert!(lockfile.contains(r#"name = "d2""#), "d2 not found\n{}", lockfile);
assert!(lockfile.contains(r#"name = "d3""#), "d3 not found\n{}", lockfile);
-})
+});
assert_that(p.cargo_process("fetch"),
execs().with_status(0).with_stdout(""));
-})
+});
fs::rename(&p.root().join("src/a.rs"), &p.root().join("src/b.rs")).assert();
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(101));
-})
+});
test!(modify_only_some_files {
let p = project("foo")
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = path2url(p.root()))));
assert_that(&p.bin("foo"), existing_file());
-})
+});
File::create(&lockfile).write_str(lock.as_slice()).assert();
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0));
-})
+});
test!(adding_and_removing_packages {
let p = project("foo")
execs().with_status(0));
let lock4 = File::open(&lockfile).read_to_string().assert();
assert_eq!(lock1, lock4);
-})
+});
test!(preserve_metadata {
let p = project("foo")
execs().with_status(0));
let lock = File::open(&lockfile).read_to_string().assert();
assert!(lock.as_slice().contains(metadata.trim()), "{}", lock);
-})
+});
assert_that(cargo_process("build").cwd(paths::root().join("foo")),
execs().with_status(0));
-})
+});
test!(simple_bin {
os::setenv("USER", "foo");
assert_that(&paths::root().join(format!("foo/target/foo{}",
os::consts::EXE_SUFFIX)),
existing_file());
-})
+});
test!(simple_git {
let td = TempDir::new("cargo").unwrap();
assert_that(cargo_process("build").cwd(td.path().clone().join("foo")),
execs().with_status(0));
-})
+});
test!(simple_travis {
os::setenv("USER", "foo");
assert_that(cargo_process("build").cwd(paths::root().join("foo")),
execs().with_status(0));
-})
+});
test!(no_argument {
assert_that(cargo_process("new"),
cargo new [options] <path>
cargo new -h | --help
"));
-})
+});
test!(existing {
let dst = paths::root().join("foo");
execs().with_status(101)
.with_stderr(format!("Destination `{}` already exists\n",
dst.display())));
-})
+});
test!(invalid_characters {
assert_that(cargo_process("new").arg("foo.rs"),
execs().with_status(101)
.with_stderr("Invalid character `.` in crate name: `foo.rs`"));
-})
+});
test!(finds_author_user {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
let toml = td.path().join("foo/Cargo.toml");
let toml = File::open(&toml).read_to_string().assert();
assert!(toml.as_slice().contains(r#"authors = ["foo"]"#));
-})
+});
test!(finds_author_username {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
let toml = td.path().join("foo/Cargo.toml");
let toml = File::open(&toml).read_to_string().assert();
assert!(toml.as_slice().contains(r#"authors = ["foo"]"#));
-})
+});
test!(finds_author_git {
my_process("git").args(&["config", "--global", "user.name", "bar"])
let toml = paths::root().join("foo/Cargo.toml");
let toml = File::open(&toml).read_to_string().assert();
assert!(toml.as_slice().contains(r#"authors = ["bar <baz>"]"#));
-})
+});
test!(author_prefers_cargo {
my_process("git").args(&["config", "--global", "user.name", "bar"])
let toml = File::open(&toml).read_to_string().assert();
assert!(toml.as_slice().contains(r#"authors = ["new-foo <new-bar>"]"#));
assert!(!root.join("foo/.gitignore").exists());
-})
+});
test!(git_prefers_command_line {
let root = paths::root();
.env("USER", Some("foo")),
execs().with_status(0));
assert!(td.path().join("foo/.gitignore").exists());
-})
+});
test!(subpackage_no_git {
os::setenv("USER", "foo");
is_not(existing_file()));
assert_that(&paths::root().join("foo/components/subcomponent/.gitignore"),
is_not(existing_file()));
-})
+});
fname == b"foo-0.0.1/src/main.rs",
"unexpected filename: {}", f.filename())
}
-})
+});
test!(metadata_warning {
let p = project("all")
verifying = VERIFYING,
compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
test!(package_verbose {
let root = paths::root().join("all");
",
packaging = PACKAGING,
archiving = ARCHIVING).as_slice()));
-})
+});
test!(package_verification {
let p = project("all")
verifying = VERIFYING,
compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
dir = p.root().display(),
url = p.url(),
)));
-})
+});
test!(top_level_overrides_deps {
let mut p = project("foo");
sep = path::SEP,
prefix = os::consts::DLL_PREFIX,
suffix = os::consts::DLL_SUFFIX).as_slice()));
-})
+});
fname == b"foo-0.0.1/src/main.rs",
"unexpected filename: {}", file.filename())
}
-})
+});
test!(git_deps {
let p = project("foo")
all dependencies must come from the same source.
dependency `foo` comes from git://path/to/nowhere instead
"));
-})
+});
test!(path_dependency_no_version {
let p = project("foo")
all path dependencies must have a version specified when publishing.
dependency `bar` does not specify a version
"));
-})
+});
updating = UPDATING,
dir = p.url(),
reg = r::registry()).as_slice()));
-})
+});
test!(deps {
let p = project("foo")
compiling = COMPILING,
dir = p.url(),
reg = r::registry()).as_slice()));
-})
+});
test!(nonexistent {
let p = project("foo")
location searched: registry file://[..]
version required: >= 0.0.0
"));
-})
+});
test!(bad_cksum {
let p = project("foo")
Caused by:
Failed to verify the checksum of `bad-cksum v0.0.1 (registry file://[..])`
"));
-})
+});
test!(update_registry {
let p = project("foo")
compiling = COMPILING,
dir = p.url(),
reg = r::registry()).as_slice()));
-})
+});
test!(package_with_path_deps {
let p = project("foo")
compiling = COMPILING,
dir = p.url(),
)));
-})
+});
test!(lockfile_locks {
let p = project("foo")
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(""));
-})
+});
test!(lockfile_locks_transitively {
let p = project("foo")
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(""));
-})
+});
test!(yanks_are_not_used {
let p = project("foo")
{compiling} foo v0.0.1 ({dir})
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
test!(relying_on_a_yank_is_bad {
let p = project("foo")
location searched: registry file://[..]
version required: = 0.0.2
"));
-})
+});
test!(yanks_in_lockfiles_are_ok {
let p = project("foo")
location searched: registry file://[..]
version required: *
"));
-})
+});
test!(update_with_lockfile_if_packages_missing {
let p = project("foo")
{updating} registry `[..]`
{downloading} bar v0.0.1 (registry file://[..])
", updating = UPDATING, downloading = DOWNLOADING).as_slice()));
-})
+});
test!(update_lockfile {
let p = project("foo")
{compiling} foo v0.0.1 ({dir})
", downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
test!(dev_dependency_not_used {
let p = project("foo")
{compiling} foo v0.0.1 ({dir})
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
test!(login_with_no_cargo_dir {
let home = paths::home().join("new-home");
.cwd(paths::root())
.env("HOME", Some(home)),
execs().with_status(0));
-})
+});
test!(bad_license_file {
let p = project("all")
execs().with_status(101)
.with_stderr("\
the license file `foo` does not exist"));
-})
+});
test!(updating_a_dep {
let p = project("foo")
{compiling} foo v0.0.1 ({dir})
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
test!(git_and_registry_dep {
let b = git::repo(&paths::root().join("b"))
println!("second");
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(""));
-})
+});
test!(update_publish_then_update {
let p = project("foo")
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
dir = path2url(p.root()),
sep = path::SEP).as_slice()));
assert_that(&p.bin("foo"), existing_file());
-})
+});
test!(simple_with_args {
let p = project("foo")
assert_that(p.cargo_process("run").arg("hello").arg("world"),
execs().with_status(0));
-})
+});
test!(exit_code {
let p = project("foo")
assert_that(p.cargo_process("run"),
execs().with_status(2));
-})
+});
test!(no_main_file {
let p = project("foo")
execs().with_status(101)
.with_stderr("a bin target must be available \
for `cargo run`\n"));
-})
+});
test!(too_many_bins {
let p = project("foo")
.with_stderr("`cargo run` requires that a project only \
have one executable. Use the `--bin` option \
to specify which one to run\n"));
-})
+});
test!(specify_name {
let p = project("foo")
",
running = RUNNING,
sep = path::SEP).as_slice()));
-})
+});
test!(run_example {
let p = project("foo")
running = RUNNING,
dir = path2url(p.root()),
sep = path::SEP).as_slice()));
-})
+});
test!(either_name_or_example {
let p = project("foo")
execs().with_status(1)
.with_stderr("specify either `--bin` or `--example`, \
not both"));
-})
+});
test!(one_bin_multiple_examples {
let p = project("foo")
running = RUNNING,
dir = path2url(p.root()),
sep = path::SEP).as_slice()));
-})
+});
test!(run_dylib_dep {
let p = project("foo")
assert_that(p.cargo_process("run").arg("hello").arg("world"),
execs().with_status(0));
-})
+});
test!(release_works {
let p = project("foo")
dir = path2url(p.root()),
sep = path::SEP).as_slice()));
assert_that(&p.release_bin("foo"), existing_file());
-})
+});
test!(run_bin_different_name {
let p = project("foo")
"#);
assert_that(p.cargo_process("run"), execs().with_status(0));
-})
+});
execs().with_status(0).with_stdout(format!("\
{updating} registry `[..]`
hoare (0.1.1) Design by contract style assertions for Rust", updating = UPDATING)));
-})
+});
",
COMPILING, p.url(),
RUNNING)));
-})
+});
test!(cargo_test_verbose {
let p = project("foo")
",
compiling = COMPILING, url = p.url(), running = RUNNING)));
-})
+});
test!(many_similar_names {
let p = project("foo")
assert!(output.contains("test bin_test"), "bin_test missing\n{}", output);
assert!(output.contains("test lib_test"), "lib_test missing\n{}", output);
assert!(output.contains("test test_test"), "test_test missing\n{}", output);
-})
+});
test!(cargo_test_failing_test {
let p = project("foo")
task '<main>' panicked at 'Some tests failed', [..]
"))
.with_status(101));
-})
+});
test!(test_with_lib_dep {
let p = project("foo")
",
COMPILING, p.url(), running = RUNNING, doctest = DOCTEST)))
-})
+});
test!(test_with_deep_lib_dep {
let p = project("bar")
compiling = COMPILING, running = RUNNING,
doctest = DOCTEST,
dir = p.url()).as_slice()));
-})
+});
test!(external_test_explicit {
let p = project("foo")
",
COMPILING, p.url(), running = RUNNING, doctest = DOCTEST)))
-})
+});
test!(external_test_implicit {
let p = project("foo")
",
COMPILING, p.url(), running = RUNNING, doctest = DOCTEST)))
-})
+});
test!(dont_run_examples {
let p = project("foo")
"#);
assert_that(p.cargo_process("test"),
execs().with_status(0));
-})
+});
test!(pass_through_command_line {
let p = project("foo")
compiling = COMPILING, running = RUNNING,
doctest = DOCTEST,
dir = p.url()).as_slice()));
-})
+});
// Regression test for running cargo-test twice with
// tests in an rlib
assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_status(0));
}
-})
+});
test!(lib_bin_same_name {
let p = project("foo")
",
COMPILING, p.url(), running = RUNNING, doctest = DOCTEST)))
-})
+});
test!(lib_with_standard_name {
let p = project("foo")
",
compiling = COMPILING, running = RUNNING,
doctest = DOCTEST, dir = p.url()).as_slice()));
-})
+});
test!(lib_with_standard_name2 {
let p = project("foo")
",
compiling = COMPILING, running = RUNNING,
dir = p.url()).as_slice()));
-})
+});
test!(bin_there_for_integration {
let p = project("foo")
let output = str::from_utf8(output.output.as_slice()).assert();
assert!(output.contains("main_test ... ok"), "no main_test\n{}", output);
assert!(output.contains("test_test ... ok"), "no test_test\n{}", output);
-})
+});
test!(test_dylib {
let p = project("foo")
running = RUNNING,
doctest = DOCTEST)));
-})
+});
test!(test_twice_with_build_cmd {
let p = project("foo")
",
running = RUNNING,
doctest = DOCTEST)));
-})
+});
test!(test_then_build {
let p = project("foo")
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(""));
-})
+});
test!(test_no_run {
let p = project("foo")
",
compiling = COMPILING,
dir = p.url()).as_slice()));
-})
+});
test!(test_run_specific_bin_target {
let prj = project("foo")
assert_that(prj.cargo_process("test").arg("--test").arg("bin2"),
execs().with_status(0).with_stdout(expected_stdout.as_slice()));
-})
+});
test!(test_run_specific_test_target {
let prj = project("foo")
assert_that(prj.cargo_process("test").arg("--test").arg("b"),
execs().with_status(0).with_stdout(expected_stdout.as_slice()));
-})
+});
test!(test_no_harness {
let p = project("foo")
",
compiling = COMPILING, running = RUNNING,
dir = p.url()).as_slice()));
-})
+});
test!(selective_testing {
let p = project("foo")
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n
", compiling = COMPILING, running = RUNNING,
dir = p.url()).as_slice()));
-})
+});
test!(almost_cyclic_but_not_quite {
let p = project("a")
assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_status(0));
-})
+});
test!(build_then_selective_test {
let p = project("a")
assert_that(p.process(cargo_dir().join("cargo")).arg("test")
.arg("-p").arg("b"),
execs().with_status(0));
-})
+});
test!(example_dev_dep {
let p = project("foo")
.file("bar/src/lib.rs", r#"
#![feature(macro_rules)]
// make sure this file takes awhile to compile
- macro_rules! f0( () => (1u) )
- macro_rules! f1( () => ({(f0!()) + (f0!())}) )
- macro_rules! f2( () => ({(f1!()) + (f1!())}) )
- macro_rules! f3( () => ({(f2!()) + (f2!())}) )
- macro_rules! f4( () => ({(f3!()) + (f3!())}) )
- macro_rules! f5( () => ({(f4!()) + (f4!())}) )
- macro_rules! f6( () => ({(f5!()) + (f5!())}) )
- macro_rules! f7( () => ({(f6!()) + (f6!())}) )
- macro_rules! f8( () => ({(f7!()) + (f7!())}) )
- macro_rules! f9( () => ({(f8!()) + (f8!())}) )
- macro_rules! f10( () => ({(f9!()) + (f9!())}) )
- macro_rules! f11( () => ({(f10!()) + (f10!())}) )
+ macro_rules! f0( () => (1u) );
+ macro_rules! f1( () => ({(f0!()) + (f0!())}) );
+ macro_rules! f2( () => ({(f1!()) + (f1!())}) );
+ macro_rules! f3( () => ({(f2!()) + (f2!())}) );
+ macro_rules! f4( () => ({(f3!()) + (f3!())}) );
+ macro_rules! f5( () => ({(f4!()) + (f4!())}) );
+ macro_rules! f6( () => ({(f5!()) + (f5!())}) );
+ macro_rules! f7( () => ({(f6!()) + (f6!())}) );
+ macro_rules! f8( () => ({(f7!()) + (f7!())}) );
+ macro_rules! f9( () => ({(f8!()) + (f8!())}) );
+ macro_rules! f10( () => ({(f9!()) + (f9!())}) );
+ macro_rules! f11( () => ({(f10!()) + (f10!())}) );
pub fn bar() {
f11!();
}
"#);
assert_that(p.cargo_process("test"),
execs().with_status(0));
-})
+});
test!(selective_testing_with_docs {
let p = project("foo")
", compiling = COMPILING, running = RUNNING, dir = p.url(),
doctest = DOCTEST).as_slice()));
-})
+});
test!(example_bin_same_name {
let p = project("foo")
execs().with_status(0).with_stdout("bin\n"));
assert_that(p.process(p.bin("examples/foo")),
execs().with_status(0).with_stdout("example\n"));
-})
+});
test!(test_with_example_twice {
let p = project("foo")
assert_that(p.process(cargo_dir().join("cargo")).arg("test").arg("-v"),
execs().with_status(0));
assert_that(&p.bin("examples/foo"), existing_file());
-})
+});
execs().with_status(0).with_stdout(format!("{}\n",
cargo::version()).as_slice()));
-})
+});
let buf = rx.read_to_end().unwrap();
assert_that(buf.as_slice(), shell_writes("Hey Alex\n"));
-})
+});
test!(color_explicitly_disabled {
let config = ShellConfig { color: false, verbose: true, tty: true };
});
let buf = rx.read_to_end().unwrap();
assert_that(buf.as_slice(), shell_writes("Hey Alex\n"));
-})
+});
test!(colored_shell {
let term = TerminfoTerminal::new(MemWriter::new());
assert_that(buf.as_slice(),
shell_writes(colored_output("Hey Alex\n",
color::RED).assert()));
-})
+});
fn colored_output<S: Str>(string: S, color: color::Color) -> IoResult<String> {
let mut term = TerminfoTerminal::new(MemWriter::new()).unwrap();
extern crate log;
mod support;
-macro_rules! test(
+macro_rules! test {
($name:ident $expr:expr) => (
#[test]
fn $name() {
$expr;
}
)
-)
+}
mod test_cargo;
mod test_cargo_bench;